﻿using System.Linq;
using Stimulus360.Models.Common;
using System.Collections.Generic;

namespace Stimulus360.Models.Data
{

    /// <summary>
    ///     This is a partial class for the ProjectRating entity to add custom functionality.
    /// </summary>
    public partial class ProjectRating
    {
        /// <summary>
        ///     Boolean indicating if there are any rule voilations in the Project Rating definition
        /// </summary>
        public bool IsValid
        {
            get { return (GetRuleViolations().Count() == 0); }
        }

        /// <summary>
        ///     Method to get the list of Rule Voilations for the current Project Rating instance
        /// </summary>
        /// <returns>
        ///     List of RuleVoilations if any
        /// </returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
            Justification = "Method use is appropriate considering complexity and logic http://msdn.microsoft.com/en-us/library/bzwdh01d(VS.71).aspx#cpconpropertyusageguidelinesanchor1")]
        public IEnumerable<RuleViolation> GetRuleViolations()
        {
            if (string.IsNullOrEmpty(Subject))
                yield return new RuleViolation(Resources.Stimulus360.Rule_IdeasSubject, "Subject");

            yield break;
        }


    }
}
